package com.lwb.ztx.api;

import com.lwb.ztx.utils.LogUtils;

import java.util.Random;

/**
 * Created by luweibin on 2016/5/27.
 */
public class Api {

    public static final String URL = "http://api.iclient.ifeng.com/ClientNews?id=";
    public static final String VIDEO_URL = "http://api.iclient.ifeng.com/ifengvideoList?gv=5.2" +
            ".0&av=5.2.0&uid=866375021181754&deviceid=866375021181754&proid=ifengnews&os" +
            "=android_19&df=androidphone&vt=5&page=";

    public static final String VIDEO_URL_TYPE = "http://api.iclient.ifeng.com/ifengvideoList?gv=5" +
            ".2.0&av=5.2.0&uid=866375021181754&deviceid=866375021181754&proid=ifengnews&os" +
            "=android_19&df=androidphone&vt=5&listtype=list";

    public static final String COMMENT_END = "&gv=5.2.0&av=5.2" +
            ".0&uid=866375021181754&screen=720x1280&userId=";
    public final static String USER_ID;
    public final static String END;

    static {
        StringBuilder stringBuilder = new StringBuilder();
        Random r = new Random();
        for (int i = 0; i < 15; i++) {
            stringBuilder.append(String.valueOf(r.nextInt(10)));
        }
        USER_ID = stringBuilder.toString();
        END = COMMENT_END + USER_ID;
    }

    public static String getUrl(String url, int page) {
        if (null == url) {
            return URL + "NBAPD&page=" + page + END;
        } else {
            if (url.contains(".php")) {
                return url + "?count=15" + END;
            }
            String newUrl = url + "&page=" + page + END;
            LogUtils.d(newUrl);
            return newUrl;
        }
    }

    public static String getVideoUrl(int page) {
        return VIDEO_URL + page;
    }
    public static String getVideoUrlByType(int page, String type) {
        return VIDEO_URL_TYPE + "&page="+ page + "&typeid=" + type;
    }



    public static String getTotlProfileUrl() {
        return "http://api.iclient.ifeng.com/totalProfile";
    }

}
